# step 1. 导入库
from launch import LaunchDescription # 从launch中导入LaunchDescription
from launch_ros.actions import Node # 从launch_ros.actions中导入Node

# step 2. 定义函数名称为：generate_launch_description
def generate_launch_description():
    # step 3. 创建Actions.Node对象bot_python_node，标明所在位置
    bot_python_node = Node(
        package="node_py_test",
        executable="bot_python_node",
        parameters=[{'writer_timer_period': 1}] # add parameter
        )
    # 创建Actions.Node对象bot_node，标明所在位置
    bot_node = Node(
        package="node_cpp_test",
        executable="bot_node",
        parameters=[{'book_price': 3}] # add parameter
        )
    # 使用 namespace 区分同名节点
    bot_python_node = Node(
        package="node_py_test",
        namespace="mirror_town",
        executable="bot_python_node",
        parameters=[{'writer_timer_period': 1}] # add parameter
        )
    # 创建Actions.Node对象bot_node，标明所在位置
    bot_node = Node(
        package="node_cpp_test",
        namespace="mirror_town",
        executable="bot_node",
        parameters=[{'book_price': 3}] # add parameter
        )
    # step 4. 创建LaunchDescription对象launch_description,用于描述launch文件
    launch_description = LaunchDescription([bot_python_node,bot_node])
    # 返回让ROS2根据launch描述执行节点
    return launch_description